Skip to content

Test the ExodusII, CGNS and Triangle mesh readers, and load Triangle meshes without a facet file - #5751

Open
pbrubeck wants to merge 8 commits into
releasefrom
pbrubeck/test/mesh-formats
Open

pbrubeck wants to merge 8 commits into
releasefrom
pbrubeck/test/mesh-formats

Conversation

@pbrubeck

@pbrubeck pbrubeck commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

CI builds PETSc without ExodusII, so the fixture in test_exodus_mesh.py skipped every ExodusII test. No test read a CGNS or a Triangle mesh file.

 # .github/actions/install/action.yml
 ./configure ... \
   --download-slepc \
+  --download-exodusii \
+  --download-cgns

Default installs from firedrake-configure do not change. The new markers skipexodusii and skipcgns never skip on CI, because CI sets FIREDRAKE_CI=1. If a package drops out of the CI build, its tests fail instead of being skipped.

_skip_test_dependency checks exodusii and cgns in the same way as MUMPS and hypre.

New tests in test_load_mesh.py:

  • Triangle: the test writes a .node/.ele/.edge mesh of the unit square to tmp_path, then checks the volume and the length of the boundary with each id.
  • TetGen: the test writes a .node/.ele/.face mesh of one tetrahedron, then checks the volume and the area of the face with each id.
  • CGNS: the test writes a DMPlex of two triangles with the PETSc CGNS viewer, then checks the volume of the mesh that Mesh reads.

Fix: Triangle meshes without a facet file

The reader took the topological dimension from the facet file that it found, so a triangle mesh without a .edge file was read as an interval mesh and failed to load.

-tdim = 3 if .face exists, else 2 if .edge exists, else 1
+tdim = (vertices per cell in .ele) - 1
+read boundary ids from the .edge (2D) or .face (3D) file if it exists

Fix: TetGen meshes and files with one entry

The TetGen tests found two more bugs in the same reader:

  • A .ele file with one cell, or a facet file with one facet, failed the count check, because
    np.loadtxt returns a one-dimensional array for a file with one row.
  • The reader marked each boundary facet as DMPlex.getJoin of its vertices, which only looks one
    level up. For the three vertices of a face of a tetrahedron the join was empty, so a TetGen mesh
    with a .face file failed to load. The reader now uses DMPlex.getFullJoin.

Evidence

  • Before: on main CI, test_exodus_mesh.py::test_sidesets SKIPPED, test_exodus_mesh.py::test_create_from_file SKIPPED (run 46448051614). There were no CGNS or Triangle tests. test_load_triangle_mesh_without_edge_file fails without the fix (assert nodedim == dim).
  • After: CI on this PR runs both ExodusII tests and the CGNS test. The Triangle tests pass locally (6 passed), including test_load_triangle_mesh_without_edge_file.

Merge Danger

Door: two-way

Blast Radius: CI-only

CI builds PETSc with two more packages, which makes the build a little longer. The only library change is in the Triangle reader, which now loads meshes that it failed to load before.

AI tool: Claude Code (Claude Opus 5.5).

🤖 Generated with Claude Code

@pbrubeck pbrubeck added the LLM used An LLM was used in the production of this PR label Nov 30, 2026
@pbrubeck
pbrubeck added this pull request to stack #5752 November 30, 2026 23:15
@pbrubeck pbrubeck changed the title Test the ExodusII, CGNS and Triangle mesh readers on CI Test the ExodusII, CGNS and Triangle mesh readers, and load Triangle meshes without a facet file Nov 30, 2026

@connorjward connorjward left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should go in release

@pbrubeck
pbrubeck removed this pull request from stack #5752 December 1, 2026 09:22
@pbrubeck
pbrubeck changed the base branch from main to release December 1, 2026 09:22
@pbrubeck
pbrubeck force-pushed the pbrubeck/test/mesh-formats branch from 1fa82c0 to acecfef Compare December 1, 2026 09:26
@pbrubeck

pbrubeck commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

This should go in release

Done

Comment thread tests/firedrake/conftest.py Resolved


@pytest.fixture
def triangle_mesh(triangle_mesh_files):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a helpful fixture name

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Triangle is another mesh format. It's like saying exodus_mesh

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is very confusing having triangle_mesh_files and triangle_mesh, where the latter also modifies the former.

Comment thread .github/actions/install/action.yml Outdated
if [ ${{ inputs.os }} = 'linux' ]; then
NPROCS=8
# Use Ubuntu's parallel HDF5 prefix and the NetCDF that PETSc builds.
hdf5_prefix="/usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)/hdf5/openmpi"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We know the OS. This doesn't have to be this confusing. Also we use the apt netcdf and pnetcdf. We should not be overwriting those here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is that ExodusII needs netcdf (not pnetcdf) with parallel I/O, and the one from apt does not have parallel I/O.

Comment thread .github/actions/install/action.yml Outdated
--with-make-np=$NPROCS \
--download-slepc
--download-slepc \
--download-exodusii \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this flag works on macOS just fine? Otherwise I don't know why it wouldn't be in EXTRA_CONFIGURE_OPTIONS

Comment thread firedrake/mesh.py Resolved
Comment thread firedrake/mesh.py Outdated

tolerance = kwargs.get("tolerance", 0.5)
if coordinates is not None:
return make_mesh_from_coordinates(coordinates, name, tolerance=tolerance)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no idea why this change is in this PR

@pbrubeck
pbrubeck force-pushed the pbrubeck/test/mesh-formats branch from b59d7d2 to 15a5ca6 Compare December 1, 2026 23:39
@pbrubeck pbrubeck added the ci:macos Run the test suite on the Mac runners label Dec 1, 2026
@pbrubeck
pbrubeck force-pushed the pbrubeck/test/mesh-formats branch 2 times, most recently from 562e94a to 649bd7f Compare December 2, 2026 00:07

@connorjward connorjward left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not happy by the significant deviations this introduces between what users are getting with firedrake-configure, and what we are actually testing in CI.

Comment thread .github/actions/install/action.yml Outdated

if [ ${{ inputs.os }} = 'linux' ]; then
NPROCS=8
: # ExodusII needs a NetCDF with parallel I/O, and the NetCDF of apt has none.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see a libnetcdf-mpi apt package, why can't we use that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found libnetcdf-pnetcdf-dev, which seems to include parallel I/O in netcdf

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appended it to the system packages

Comment thread .github/actions/install/action.yml Outdated
libdir=/usr/lib/x86_64-linux-gnu
EXTRA_CONFIGURE_OPTIONS+=(
--download-netcdf
--with-pnetcdf-dir=/usr

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we suddenly need to pass this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread .github/actions/install/action.yml Outdated
--download-netcdf
--with-pnetcdf-dir=/usr
"--download-cgns-cmake-arguments=-DHDF5_ROOT:PATH=$libdir/hdf5/openmpi"
"--download-exodusii-cmake-arguments=-DHDF5_ROOT:PATH=$libdir/hdf5/openmpi -DPnetcdf_LIBRARY_DIRS:PATH=$libdir"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have expected these to work without since we are telling PETSc which HDF5 we are using. I can imagine that that wouldn't be the case though.

@pbrubeck

pbrubeck commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor Author

I am not happy by the significant deviations this introduces between what users are getting with firedrake-configure, and what we are actually testing in CI.

Do you want firedrake-configure to install exodsii and cgns by default?

@connorjward

Copy link
Copy Markdown
Contributor

I am not happy by the significant deviations this introduces between what users are getting with firedrake-configure, and what we are actually testing in CI.

Do you want firedrake-configure to install exodsii and cgns by default?

Unsure. Do they take a long time to build? And what about macOS/complex?

The message of the ValueError was not an f-string, so it printed
'{dependency = }' instead of the name of the dependency.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pbrubeck
pbrubeck force-pushed the pbrubeck/test/mesh-formats branch from 86efe0d to dbf80c3 Compare December 3, 2026 11:18
@pbrubeck pbrubeck added ci:complex Run the test suite in complex mode ci:int64 Do a 64 bit integer build labels Dec 3, 2026
pbrubeck and others added 7 commits December 3, 2026 11:18
CI built PETSc without ExodusII, so the fixture in test_exodus_mesh.py
skipped every ExodusII test. Add --download-exodusii and --download-cgns
to the official configurations of firedrake-configure, which CI uses,
and mark the tests with skipexodusii, which never skips on CI.

On Ubuntu, ExodusII needs a NetCDF with parallel I/O, so install the
PnetCDF build of NetCDF from apt (libnetcdf-pnetcdf-dev). PETSc v3.26.0
needs the PnetCDF directory to configure ExodusII
(https://gitlab.com/petsc/petsc/-/work_items/2019), and the CMake builds
of CGNS and ExodusII need the paths to the HDF5 and NetCDF libraries
from apt, because CMake does not search them.

Co-authored-by: Codex <codex@openai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
np.loadtxt returns a one-dimensional array for a file with one row, so
the reader took the number of vertices of the only cell for the number
of cells, and failed its check of the cell count. Read the cells and the
facets as two-dimensional arrays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reader found each boundary facet as the join of its vertices with
DMPlex.getJoin, which only looks one level up, at the edges. The three
vertices of a face of a tetrahedron share no edge, so the join was empty
and the reader failed. Use DMPlex.getFullJoin, which finds the face.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No test read a Triangle, a TetGen or a CGNS mesh file. Check the volume
and the boundary ids of a Triangle mesh of the unit square and of a
TetGen mesh of one tetrahedron, and the volume of a unit square that
PETSc writes to a CGNS file.

Co-authored-by: Codex <codex@openai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Triangle reader took the topological dimension from the facet file
that it found. Without a .edge or .face file it assumed an interval mesh,
so a triangle mesh failed to load. Take the topological dimension from
the number of vertices of each cell in the .ele file, and read boundary
ids only if the facet file exists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Apply https://gitlab.com/petsc/petsc/-/merge_requests/9901 to the PETSc
that CI builds, and remove --with-pnetcdf-dir=/usr, to check that
ExodusII configures with the PnetCDF that PETSc finds on its own.

Drop this commit before merge. The PETSc v3.26.0 that release builds
does not have the fix, so firedrake-configure on release needs
--with-pnetcdf-dir=/usr.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pbrubeck
pbrubeck force-pushed the pbrubeck/test/mesh-formats branch from dbf80c3 to cdaa721 Compare December 3, 2026 11:18
@pbrubeck

pbrubeck commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

Do you want firedrake-configure to install exodsii and cgns by default?

Unsure. Do they take a long time to build? And what about macOS/complex?

They don't take long.

Job Extra configure time Configure (release → PR) Change in make
Linux default about +30 s (CGNS 12 s, ExodusII 8–19 s) 34–37 s → 67 s none (67 s)
macOS +50–110 s (CGNS 13 s, ExodusII 46–78 s) 968–1010 s → 1060–1082 s +0–15 s

"-DHDF5_ROOT:PATH=/usr/lib/x86_64-linux-gnu/hdf5/openmpi "
"-DPnetcdf_LIBRARY_DIRS:PATH=/usr/lib/x86_64-linux-gnu "
"-DnetCDF_DIR:PATH=/usr/lib/x86_64-linux-gnu/cmake/netCDF_pnetcdf'",
"--with-ptscotch",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pbrubeck

pbrubeck commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

I will have to retarget this PR to main, because the PETSc fixes will have to land on main.

https://gitlab.com/petsc/petsc/-/merge_requests/9904#note_4388123655

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:complex Run the test suite in complex mode ci:int64 Do a 64 bit integer build ci:macos Run the test suite on the Mac runners LLM used An LLM was used in the production of this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants